namespace MyHomeworkWebAPi.Models.response
{
    public class ApiResponse<T>
    {
        public required string Message { get; set; }
        public required T Data { get; set; }
        public int Code { get; set; }

        public static ApiResponse<T> SuccessResponse(T data, string message = "操作成功")
        {
            return new ApiResponse<T>
            {
                Message = message,
                Data = data,
                Code = 200
            };
        }

        public static ApiResponse<T> ErrorResponse(string message, int code = 400)
        {
            return new ApiResponse<T>
            {
                Message = message,
                Data = default!,
                Code = code
            };
        }
    }
}
